package edu.gatech.oops.servlets;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class viewTeams
 */
public class viewTeams extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public viewTeams() {
        super();
        // TODO Auto-generated constructor stub
    }
    
    protected void processRequest(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
    	PrintWriter out = response.getWriter();
    	String CourseName = request.getParameter("courseName");
		String labName = request.getParameter("labName");
		File file = new File("/home/pushkara/workspace/LabAssistan/"+CourseName+"_"+labName+".txt");
		BufferedReader reader = new BufferedReader(new FileReader(file));
		reader.readLine();
		String line = reader.readLine();
		out.println("<html>");
		out.println("<head>");
		out.println("<title>TEAMSSSS AWWW YEEEEEEEAH</title>");
		out.println("</head>");
		
		out.println("<body>");
		out.println("<h2>List of Teams</h2>");
		while(line!=null){
			String[] data = line.split(",");
			//out.println("<tr>");
			out.println(data[0]+"  :  "+data[1]);
			out.println("<tr></tr>");
			line = reader.readLine();
		}
		out.close();
		
    	
    }
	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		processRequest(request, response);
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		processRequest(request, response);
		// TODO Auto-generated method stub
	}

}
